/*
 * @Author: taoyuqing
 * @Date: 2023-03-25 07:06:40
 * @Description: RestPassword
 */
import 'package:flutter/material.dart';
import 'package:flutter/material.dart';
import 'package:flutter_easyloading/flutter_easyloading.dart';
import 'package:flutter_svg/svg.dart';
import 'package:shared_preferences/shared_preferences.dart';
import 'package:spree/utils/api.dart';
import 'package:spree/widgets/common_container.dart';

class RestPassword extends StatefulWidget {
  final Function? onLogin;
  RestPassword({Key? key, this.onLogin}) : super(key: key);

  @override
  State<RestPassword> createState() => _RestPasswordState();
}

class _RestPasswordState extends State<RestPassword> {
  TextEditingController _oldPassword = TextEditingController();
  TextEditingController _newPassword = TextEditingController();
  TextEditingController _confirmPassword = TextEditingController();
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('重置密码'),
      ),
      body: CommonContainer(
        child: ListView(
          padding: EdgeInsets.only(top: 100),
          children: [
            SvgPicture.asset(
              'images/BETSPREELOGO.svg',
              width: 200,
            ),
            Container(
              margin: EdgeInsets.only(top: 20),
              padding: EdgeInsets.only(left: 20, right: 20),
              decoration: BoxDecoration(
                  borderRadius: const BorderRadius.all(Radius.circular(8.0)),
                  border: Border.all(
                      width: 1, color: Color.fromRGBO(255, 255, 255, 0.5))),
              child: TextField(
                style: TextStyle(color: Colors.white),
                cursorColor: Colors.white,
                decoration: InputDecoration(
                    suffix: Icon(
                      Icons.remove_red_eye_outlined,
                      color: Color.fromRGBO(255, 255, 255, 0.5),
                    ),
                    icon: Icon(
                      Icons.lock,
                      color: Color.fromRGBO(255, 255, 255, 0.5),
                    ),
                    hintText: '原密码',
                    border: InputBorder.none,
                    hintStyle: TextStyle(
                      color: Color.fromRGBO(255, 255, 255, 0.7),
                    )),
                controller: _oldPassword,
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 20),
              padding: EdgeInsets.only(left: 20, right: 20),
              decoration: BoxDecoration(
                  borderRadius: const BorderRadius.all(Radius.circular(8.0)),
                  border: Border.all(
                      width: 1, color: Color.fromRGBO(255, 255, 255, 0.5))),
              child: TextField(
                style: TextStyle(color: Colors.white),
                cursorColor: Colors.white,
                decoration: InputDecoration(
                    suffix: Icon(
                      Icons.remove_red_eye_outlined,
                      color: Color.fromRGBO(255, 255, 255, 0.5),
                    ),
                    icon: Icon(
                      Icons.lock,
                      color: Color.fromRGBO(255, 255, 255, 0.5),
                    ),
                    hintText: '输入新的密码',
                    border: InputBorder.none,
                    hintStyle: TextStyle(
                      color: Color.fromRGBO(255, 255, 255, 0.7),
                    )),
                obscureText: true,
                controller: _newPassword,
              ),
            ),
            Container(
              margin: EdgeInsets.only(top: 20),
              padding: EdgeInsets.only(left: 20, right: 20),
              decoration: BoxDecoration(
                  borderRadius: const BorderRadius.all(Radius.circular(8.0)),
                  border: Border.all(
                      width: 1, color: Color.fromRGBO(255, 255, 255, 0.5))),
              child: TextField(
                style: TextStyle(color: Colors.white),
                cursorColor: Colors.white,
                decoration: InputDecoration(
                    suffix: Icon(
                      Icons.remove_red_eye_outlined,
                      color: Color.fromRGBO(255, 255, 255, 0.5),
                    ),
                    icon: Icon(
                      Icons.lock,
                      color: Color.fromRGBO(255, 255, 255, 0.5),
                    ),
                    hintText: '确认新密码',
                    border: InputBorder.none,
                    hintStyle: TextStyle(
                      color: Color.fromRGBO(255, 255, 255, 0.7),
                    )),
                obscureText: true,
                controller: _confirmPassword,
              ),
            ),
            Container(
              height: 50,
              margin: EdgeInsets.only(top: 20),
              child: ElevatedButton(
                  style: ButtonStyle(
                    backgroundColor:
                        MaterialStateProperty.all(Color(0xFFF93967)),
                  ),
                  onPressed: () {
                    if (widget.onLogin != null) {
                      widget.onLogin!();
                    }
                    _handleRegister();
                  },
                  child: Text(
                    'Enter',
                    style: TextStyle(fontSize: 16),
                  )),
            ),
          ],
        ),
      ),
    );
  }

  _handleRegister() async {}
}
